"""
@author: xxw
@file: 06.继承.py
@time: 2023/5/4 15:52
"""
# 提高代码的复用率

# 在python3中 默认就会继承object

# 子类与父类     基类与派生类
import json


class A:
    name = "a"
    def __init__(self, count):
        print("this is A __init__")
        self.count = count
    def call(self):
        print("this is class ")

class B(A):
    # def __init__(self):         #子类没有__init__会调用父类的__init__
    #     print("this is B __init__")
    def say(self):
        print("this is class B")

# 可以多重继承，可以继承多个
class C(B):
    def __init__(self, c_name, count):
        super(C, self).__init__(count)  #在子类里面访问父类方法的时候使用
        print("this is c __init__")
        self.c_name = c_name

# b1 = B(1)
# b1.say()
# b1.call()
# print(b1.name)
# c1 = C("ccc",100)
# print(isinstance(c1, B))

class Mydict(dict):
    def load_json_file(self):
        with open("config.json") as fp:
            json_dict = json.loads(fp.read())
            self.update(json_dict)
d1 = Mydict()
d1.load_json_file()
d1["a"] = 2
print(d1)
